<template>
  <a-modal
    :visible="visible"
    :title="editId ? '修改绩点转换标准' : '新增绩点转换标准'"
    :confirmLoading="confirmLoading"
    okText='保存'
    :width="700"
    @cancel="() => { $emit('cancel') }"
    @ok="() => { $emit('create') }"
  >
    <a-form :form="form">
      <a-row>
        <a-col :md="10" :sm="24">
          <a-form-item
            label="成绩类型"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select @change="cjlxmChange" v-decorator="[
              'cjlxm',
              {
                rules: [{ required: true, message: '请选择成绩类型!' }],
              }
            ]">
              <a-select-option v-for="i in selectMenu.cjlx" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="10" :sm="24">
          <a-form-item
            label="绩点值"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['jdz',
              {
                rules: [{ required: true, message: '请选择成绩类型!' }],
              }
            ]"/>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col v-if="cjlxm === '02'" :md="10" :sm="24">
          <a-form-item
            label="分数等级"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['jsfs']"/>
          </a-form-item>
        </a-col>
        <a-col v-if="cjlxm === '01'" :md="10" :sm="24">
          <a-form-item
            label="开始分数"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['ksfs']"/>
          </a-form-item>
        </a-col>
        <a-col v-if="cjlxm === '01'" :md="10" :sm="24">
          <a-form-item
            label="结束分数"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="['jsfs']"/>
          </a-form-item>
        </a-col>
        <a-col :md="10" :sm="24">
          <a-form-item
            label="是否启用"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select v-decorator="[
              'enabledFlag',
              {
                rules: [{ required: true, message: '请选择是否启用!' }],
              }
            ]">
              <a-select-option v-for="i in selectMenu.enableFlag" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
      </a-row>
      <a-form-item label="备注" :labelCol="{span: 2,offset: 2}" :wrapperCol="{span: 16}">
        <a-input type="textarea" v-decorator="['note']" :autosize="{ minRows: 2, maxRows: 6 }"/>
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script>
export default {
  props: ['visible', 'editId', 'selectMenu', 'confirmLoading'],
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  data () {
    return {
      cjlxm: ''
    }
  },
  methods: {
    cjlxmChange(code) {
      this.cjlxm = code
    }
  }
}
</script>

<style>

</style>
